# -*- coding: utf-8 -*-
"""
main
2025/9/9
@author: zhangzida
"""
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
class Base():
    def __init__(self,driver):
        self.driver=driver
    # 打开网址
    def open_url(self,url):
        self.driver.get(url)
    # 等待
    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,20,0.5).until(lambda driver: self.driver.find_element(*loc).is_displayed())
            return self.driver.find_element(*loc)
        except Exception as e:
            print(e)
    # 点击
    def click(self,loc):
        self.find_element(loc).click()
    # 输入
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    # 文本断言
    def text(self,loc):
        return self.find_element(loc).text
    # 键盘回车事件
    def enter(self,loc):
        self.find_element(loc).send_keys(Keys.ENTER)
    # 滑动
    def scrollTo(self):
        self.driver.switch_to.window('window.scrollTo(0,700)')